package biz.impl;

import java.util.List;

import com.alibaba.fastjson.JSONObject;

import biz.MusicBiz;
import entity.PlayerList;
import entity.SongInfo;
import util.HibernateUtils;

public class MusicBizImpl implements MusicBiz {

	// 根据类型获取音乐列表
	@SuppressWarnings("unchecked")
	@Override
	public List<SongInfo> musicList(String type, Integer firstIndex, Integer maxSums) {
		SongInfo songInfo = new SongInfo();
		songInfo.setType(type);
		List<SongInfo> list = HibernateUtils.getByHql(HibernateUtils.createQueryHql(songInfo), firstIndex, maxSums);
		HibernateUtils.getSession().beginTransaction().commit();
		return list;
	}

	// 获取歌曲详情
	public SongInfo musicDetails(Integer id) {
		SongInfo songInfo = HibernateUtils.getOne(SongInfo.class, id);
		return songInfo;
	}

	// 搜索歌曲
	@Override
	public JSONObject searchMusic(String keyword) {
		// TODO Auto-generated method stub
		return null;
	}

	// 根据歌曲id获取歌词
	@Override
	public JSONObject musicLRC(Integer id) {
		// TODO Auto-generated method stub
		return null;
	}

	// 获取播放列表
	@SuppressWarnings("unchecked")
	@Override
	public List<PlayerList> playerList(Integer userId) {
		PlayerList hql = new PlayerList();
		hql.setUserId(userId);
		return HibernateUtils.getByHql(HibernateUtils.createQueryHql(hql));
	}

}
